package com.wzb.mybatisplus.bitaction;

import com.wzb.mybatisplus.entity.Bituse;
import com.wzb.mybatisplus.service.IBituseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
        格式	字符长度	前缀	说明
        WIF 未压缩	51个字符	5	传统格式，不包含压缩标志
        WIF 压缩	52个字符	K 或 L	现代格式，包含压缩标志
        WIF 测试网未压缩	51个字符	9	测试网络使用
        WIF 测试网压缩	52个字符	c	测试网压缩格式
*/
@Service
public class digui {


    public static final String ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
    @Autowired
    private IBituseService bituseService;
    public static void main(String[] args) {

        //自定义线程池
        ThreadPoolExecutor threadPool = new ThreadPoolExecutor(
                25,  //核心线程数
                50,             //最大线程数
                60,            //临时线程的最长空闲时间
                TimeUnit.SECONDS,   //空闲时间的单位
                new ArrayBlockingQueue<>(100),  //传递任务的阻塞队列
                Executors.defaultThreadFactory(),   //用于创建新线程的线程工厂
                new ThreadPoolExecutor.AbortPolicy()    //超出负荷时的拒绝策略
        );

        for (int i = 0; i < 100; i++) {
            int id = i;
            threadPool.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println("hello " +  id  + " " + Thread.currentThread().getName());
                }
            });
        }

        //关闭线程池
        threadPool.shutdown();
    }



    public  void aa (String s){
        ThreadPoolExecutor threadPool = new ThreadPoolExecutor(
                25,  //核心线程数
                50,             //最大线程数
                60,            //临时线程的最长空闲时间
                TimeUnit.SECONDS,   //空闲时间的单位
                new ArrayBlockingQueue<>(100),  //传递任务的阻塞队列
                Executors.defaultThreadFactory(),   //用于创建新线程的线程工厂
                new ThreadPoolExecutor.AbortPolicy()    //超出负荷时的拒绝策略
        );



        int sum =0;
        for(int a1=0 ; a1<ALPHABET.length();a1++)
        for(int a2=0 ; a2<ALPHABET.length();a2++)
        for(int a3=0 ; a3<ALPHABET.length();a3++)
        for(int a4=0 ; a4<ALPHABET.length();a4++)
        for(int a5=0 ; a5<ALPHABET.length();a5++)
        for(int a6=0 ; a6<ALPHABET.length();a6++)
        for(int a7=0 ; a7<ALPHABET.length();a7++)
        for(int a8=0 ; a8<ALPHABET.length();a8++)
        for(int a9=0 ; a9<ALPHABET.length();a9++)
        for(int a10=0 ; a10<ALPHABET.length();a10++)
        for(int a11=0 ; a11<ALPHABET.length();a11++)
        for(int a12=0 ; a12<ALPHABET.length();a12++)
        for(int a13=0 ; a13<ALPHABET.length();a13++)
        for(int a14=0 ; a14<ALPHABET.length();a14++)
        for(int a15=0 ; a15<ALPHABET.length();a15++)
        for(int a16=0 ; a16<ALPHABET.length();a16++)
        for(int a17=0 ; a17<ALPHABET.length();a17++)
        for(int a18=0 ; a18<ALPHABET.length();a18++)
        for(int a19=0 ; a19<ALPHABET.length();a19++)
        for(int a20=0 ; a20<ALPHABET.length();a20++)
        for(int a21=0 ; a21<ALPHABET.length();a21++)
        for(int a22=0 ; a22<ALPHABET.length();a22++)
        for(int a23=0 ; a23<ALPHABET.length();a23++)
        for(int a24=0 ; a24<ALPHABET.length();a24++)
        for(int a25=0 ; a25<ALPHABET.length();a25++)
        for(int a26=0 ; a26<ALPHABET.length();a26++)
        for(int a27=0 ; a27<ALPHABET.length();a27++)
        for(int a28=0 ; a28<ALPHABET.length();a28++)
        for(int a29=0 ; a29<ALPHABET.length();a29++)
        for(int a30=0 ; a30<ALPHABET.length();a30++)
        for(int a31=0 ; a31<ALPHABET.length();a31++)
        for(int a32=0 ; a32<ALPHABET.length();a32++)
        for(int a33=0 ; a33<ALPHABET.length();a33++)
        for(int a34=0 ; a34<ALPHABET.length();a34++)
        for(int a35=0 ; a35<ALPHABET.length();a35++)
        for(int a36=0 ; a36<ALPHABET.length();a36++)
        for(int a37=0 ; a37<ALPHABET.length();a37++)
        for(int a38=0 ; a38<ALPHABET.length();a38++)
        for(int a39=0 ; a39<ALPHABET.length();a39++)
        for(int a40=0 ; a40<ALPHABET.length();a40++)
        for(int a41=0 ; a41<ALPHABET.length();a41++)
        for(int a42=0 ; a42<ALPHABET.length();a42++)
        for(int a43=0 ; a43<ALPHABET.length();a43++)
        for(int a44=0 ; a44<ALPHABET.length();a44++)
        for(int a45=0 ; a45<ALPHABET.length();a45++)
        for(int a46=0 ; a46<ALPHABET.length();a46++)
        for(int a47=0 ; a47<ALPHABET.length();a47++)
        for(int a48=0 ; a48<ALPHABET.length();a48++)
        for(int a49=0 ; a49<ALPHABET.length();a49++)
            for(int a50=0 ; a50<ALPHABET.length();a50++)
                for(int a51=0 ; a51<ALPHABET.length();a51++)
                {
                    String maney = "L";
//                     maney=maney+ ALPHABET.charAt(a1)+ALPHABET.charAt(a2)+ALPHABET.charAt(a3)+ALPHABET.charAt(a4)+ALPHABET.charAt(a5);
//                    System.out.println("===="+maney);
                    maney= maney + ALPHABET.charAt(a1)+ALPHABET.charAt(a2)+ALPHABET.charAt(a3)+ALPHABET.charAt(a4)+ALPHABET.charAt(a5)
                            +ALPHABET.charAt(a6)+ALPHABET.charAt(a7)+ALPHABET.charAt(a8)+ALPHABET.charAt(a9)+ALPHABET.charAt(a10)
                            +ALPHABET.charAt(a11)+ALPHABET.charAt(a12)+ALPHABET.charAt(a13)+ALPHABET.charAt(a14)+ALPHABET.charAt(a15)+ALPHABET.charAt(a16)
                            +ALPHABET.charAt(a17)+ALPHABET.charAt(a18)+ALPHABET.charAt(a19)+ALPHABET.charAt(a20)+ALPHABET.charAt(a21)+ALPHABET.charAt(a22)
                            +ALPHABET.charAt(a23)+ALPHABET.charAt(a24)+ALPHABET.charAt(a25)+ALPHABET.charAt(a26)+ALPHABET.charAt(a27)+ALPHABET.charAt(a28)+ALPHABET.charAt(a29)
                            +ALPHABET.charAt(a30)+ALPHABET.charAt(a31) +ALPHABET.charAt(a32)+ALPHABET.charAt(a33)+ALPHABET.charAt(a34)
                            +ALPHABET.charAt(a35)+ALPHABET.charAt(a36)+ALPHABET.charAt(a37)+ALPHABET.charAt(a38)+ALPHABET.charAt(a39)+ALPHABET.charAt(a40)
                            +ALPHABET.charAt(a41)+ALPHABET.charAt(a42)+ALPHABET.charAt(a43)+ALPHABET.charAt(a44)+ALPHABET.charAt(a45)+ALPHABET.charAt(a46)+
                            ALPHABET.charAt(a47)+ALPHABET.charAt(a48)+ALPHABET.charAt(a49)+ALPHABET.charAt(a50)+ALPHABET.charAt(a51);
//                    System.out.println(maney);

                    String maney1 = maney;
                    threadPool.submit(new Runnable() {

                        @Override
                        public void run() {
//
                            if(BitcoinWIFConverter.wifTo34CharPublicKey(maney1).equals("1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa")){
//                                sum=sum+1;
//                                System.out.println("============="+sum + "      秘钥" +maney1);
                                Bituse bituse = new Bituse();
                                bituse.setWifsy(maney1);
                                bituse.setGy("1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa");
                                bituseService.save(bituse);
                            }

                        }
                    });


                }

        //关闭线程池
        threadPool.shutdown();

    }

}
